<template>
	<view class="home">
		<!-- 头部 -->
		<view class="tops">
			<!-- #ifdef MP-WEIXIN -->
			<button class="leftBox" type="default" plain="true" open-type="contact" @contact="contact">
				<view class="left">
					<image src="https://i.postimg.cc/W4CpptQr/chat.png" mode=""></image>
				</view>
			</button>
			
			<!-- #endif -->
			<view class="right">
				<image src="https://i.postimg.cc/SsjnxwT2/search.png" mode=""></image>
				<navigator class="cart" url="/pages/user/car/car">
					<image src="https://i.postimg.cc/2SN5hq6x/cart.png" mode=""></image>
				</navigator>
				
			</view>
		</view>
		<!-- 轮播 -->
		<view class="banner">
			<swiper
				class="swiper-banner"
				previous-margin="0rpx"
				indicator-dots="true"
				indicator-color="#767574"
				indicator-active-color="#D8D8D8"
				:autoplay="true"
				:interval="3000"
				:duration="400"
			>
				<swiper-item v-for="m in bannerList" :key="m.id">
					<view class="swiper-item"><image class="img" :src="m.pic" mode="widthFix"></image></view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 类目 -->
		<view class="section-kinds">
			<navigator v-for="item in kindList" class="kind-block" :key="item.id" :url="item.url">
				<image class="icon-kind" :src="item.icon"></image>
				<view class="kind-text">{{ item.name }}</view>
			</navigator>
		</view>
		<!-- 限时活动 -->
		<view class="section-notify">
			<image src="https://i.postimg.cc/NFgRDNpQ/notify.png" class="icon-notify"></image>
			<text class="text">限时领取:</text>
			<swiper class="swiper recommend-swiper" :circular="true" :vertical="true" :indicator-dots="false" :autoplay="true" :interval="2000" :duration="1000">
				<swiper-item v-for="item in recommendList" :key="item.id" class="recommend-item">
					<navigator class="nav-item" :url="'/kindPackage/list/info/info?productId=' + item.productId">
						<view class="product-name">{{ item.name }}</view>
						<view class="product-price">
							<view class="text" style="text-decoration: line-through;color:#333;">{{ item.price }}元</view>
							<view class="text" style="color:red;">现价: {{ item.promotionPrice }}元</view>
						</view>
					</navigator>
				</swiper-item>
			</swiper>
		</view>
		<!-- 热门推荐 -->
		<view class="section-series">
			<view class="common-title"><text class="title">热门推荐</text></view>
			<view class="box">
				<swiper class="scroll-series" :display-multiple-items="3" :circular="true" :autoplay="true" :interval="3000" easing-function="linear" :duration="3000">
					<swiper-item @tap="goSeries(item.id)" class="series-block" v-for="item in hotList" :key="item.id">
						<image class="image" :src="item.pic" mode=""></image>
						<view class="cname">{{ item.name }}</view>
						<view class="ename">{{ item.ename }}</view>
					</swiper-item>
				</swiper>
			</view>
		</view>
		<!-- 新品推荐 -->
		<view class="section-series">
			<view class="common-title">
				<text class="title">新品推荐</text>
				<!-- <text class="more" @tap="seriesMore">更多></text> -->
			</view>
			<scroll-view class="newProduct" scroll-x="true">
				<view @tap="goSeries(item.id)" class="series-block" v-for="item in LatestProducts" :key="item.id">
					<image class="image" :src="item.pic" mode=""></image>
					<view class="newProductBox">
						<view class="cname">{{ item.name }}</view>
						<!-- <view class="squote">
							<view class="dots" v-for="ele in item.squote" :key="ele" :style="{background:ele}"></view>
						</view> -->
						<view class="ename">价格：{{ item.price }}</view>
					</view>
				</view>
			</scroll-view>
		</view>
		<!-- 猜你喜欢 -->
		<view class="section-series section-hot">
			<view class="common-title"><text class="title">猜你喜欢</text></view>
			<view class="pubu-box">
				<view class="pubu-item">
					<view class="item-masonry" v-for="(item, index) in saleMostProducts" :key="item.id + index">
						<image :src="item.pic" mode="widthFix"></image>
						<view class="text-area">
							<view class="gname">{{ item.brandName }}</view>
							<view class="price-origin">
								<text class="price">¥{{ item.price | money }}</text>
								<text class="origin">{{ item.origin_city }}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bannerList: [
					{
						id: "1704738953020686338",
						name: "时尚简约可爱女装甜美女生1920全屏海报",
						pic: 'https://img.zcool.cn/community/01a42d59b650c2a801211d25586944.jpg@1280w_1l_2o_100sh.jpg',
					},
					{
						id: "1704738953020686339",
						name: "关键词:春季萝莉爆款女生衣服banner 活泼校园风 韩版卫衣 从御姐到",
						pic: 'http://hbimg.b0.upaiyun.com/4d143161817cabc521e566ee3fc9b3cb14fedd13bd39-VIetCc_fw658',
					},
					{
						id: "170473895302069",
						name: "活力少女女装banner图",
						pic: 'http://hbimg.huabanimg.com/79511ddd3601b875a6fd47053dc4f065e41508c18f61d-Wp54pP_fw658',
					},
				],
				recommendList: [
					{
						id: 1,
						name: '哈士奇幼犬',
						price: '268',
						promotionPrice:'5',
					},
					{
						id: 2,
						name: '柯基幼犬',
						price: '300',
						promotionPrice:'5',
					}
				],
				hotList: [
					{
						id: 1,
						name: '藏獒幼犬',
						pic:'http://img.boqiicdn.com/Data/BK/A/1310/28/img35011382947128_y.jpg'
					},
					{
						id: 2,
						name: '哈士奇幼犬',
						pic:'http://uimg.liecdn.cn/image/post/fd/6c/ef/82/fd6cef82ddef988cd87d38968a1e0d8a.jpg'
					},
					{
						id: 3,
						name: '茶杯犬',
						pic:'https://imgservice.suning.cn/uimg1/b2c/image/WlIqlgwg6Qe94aRrnK3okw.jpg_800w_800h_4e'
					},
					{
						id: 4,
						name: '金毛幼犬',
						pic:'https://p0.ssl.qhimgs1.com/sdr/400__/t0125f3161045e8646a.jpg'
					},
				],
				LatestProducts: [
					{
						id: 1,
						name:'哈士奇',
						pic:'https://img0.baidu.com/it/u=3155484156,3023508163&fm=253&fmt=auto&app=138&f=JPEG?w=200&h=200',
						price:'888',
						promotionPrice:'688',
					},
					{
						id: 2,
						name:'金毛',
						pic:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F202001%2F18%2F20200118170220_ybnwc.thumb.1000_0.jpg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1698330041&t=6af3ef9d11331f0ae039eecfae91aae1',
						price:'888',
						promotionPrice:'688',
					},
					{
						id: 3,
						name:'柯基',
						pic:'https://img2.baidu.com/it/u=2861718613,1314475965&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
						price:'888',
						promotionPrice:'688',
					},
					{
						id: 4,
						name:'德牧',
						pic:'https://pic.bbs.ybvv.com/forum/201812/02/185753fkaayvvk7zca77ak.jpg',
						price:'888',
						promotionPrice:'688',
					},
				],
				saleMostProducts: [
					{
						id: '0',
						brandName: '泡泡',
						price: 1208,
						origin_city: '汪星人',
						pic: 'https://tupian.qqw21.com/article/UploadPic/2020-6/202062820161963234.jpg',
					},
					{
						id: '1',
						brandName: '豆豆',
						price: 999.99,
						origin_city: '汪星人',
						pic: 'https://img1.baidu.com/it/u=684353503,2500173474&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',
					},
					{
						id: '2',
						brandName: '默默',
						price: 680,
						origin_city: '汪星人',
						pic: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Fba55eed1-6ce5-463c-8e75-d6086736333d%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1698370852&t=1a033c98f1346396ca589399f9b0857a',
					},
					{
						id: '3',
						brandName: '嘟嘟',
						price: 5800,
						origin_city: '喵星人',
						pic: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F92dd9cda-da29-44c3-af9b-e71f1866ece5%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1698330860&t=c7b81fc42beac62bab74934cac5f565d',
					},
					{
						id: '4',
						brandName: '莉莉娅',
						price: 6900,
						origin_city: '喵星人',
						pic: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F93d922e0-222f-44af-9891-e250244223b5%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1698330884&t=6fc733b8675088b287874cb533896c58',
					},
					{
						id: '5',
						brandName: '小德',
						price: 6900,
						origin_city: '喵星人',
						pic: 'https://inews.gtimg.com/newsapp_bt/0/13543715647/1000',
					},
					{
						id: '6',
						brandName: '大炮',
						price: 6900,
						origin_city: '喵星人',
						pic: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201812%2F31%2F20181231154546_JsitY.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1698330931&t=d35f6229a66be2241fbf5f60d6152b06',
					},
					{
						id: '7',
						brandName: '奥斯卡',
						price: 680,
						origin_city: '汪星人',
						pic: 'https://img.mp.itc.cn/upload/20170717/07ee7cce96164b5aa86f1dcf213356a8_th.jpg',
					},
					{
						id: '8',
						brandName: '凳子',
						price: 330,
						origin_city: '汪星人',
						pic: 'http://img.duoziwang.com/2021/06/47889910941478080.jpg',
					},
				],
				kindList: [
					{
						name: '猫 咖',
						icon: 'http://pic.qqtn.com/up/2017-11/2017112417010490838.jpg',
					},
					{
						name: '狗 咖',
						icon: 'https://pic.qqtn.com/up/2019-11/2019112017124167949.jpg',
					},
					{
						name: '视 频',
						icon: 'https://pic.qqtn.com/up/2019-11/2019112017124167949.jpg',
						url: '/videoPackge/index/index',
					},
					
					// {
					// 	name: '其他',
					// 	icon: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F3f580f26-0244-4b56-81e4-dd2bf777aa77%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1698328094&t=e5809a5ed0e9f838e7fbb5405a64f948',
					// },
					
				]
			}
		},
		onLoad() {
			this.init();
		},
		onPullDownRefresh() {
			this.init();
		},
		// onReachBottom() {
		// 	uni.showLoading({
		// 		title: '加载中...'
		// 	})
		// 	const arrPicList = [
		// 		'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F202106%2F23%2F20210623175340_03f0d.thumb.1000_0.jpg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1698374555&t=4b01e18ddb9b2dfb1fc6ef1ff465b606',
		// 		'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Fa39a6c16-4124-44b5-8157-ced348323ba1%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1698374808&t=b2ced2ad7bb6b06c416766c1280b77dd',
		// 		'https://img2.baidu.com/it/u=3020140435,1413822749&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500',
		// 		'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Ffcde7783-032d-4e0f-a4f7-2da03d10c425%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1698374857&t=62d7cf73043f184f87857ed85585d7db',
		// 		'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201906%2F24%2F20190624163008_MasMY.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1698374900&t=5d7fceabc989d860c345c1d5857f7543',
		// 		'https://img1.baidu.com/it/u=1377761901,4144240349&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
		// 	]
		// 	const copyData = JSON.parse(JSON.stringify(this.saleMostProducts))
		// 	setTimeout(()=>{
		// 		this.saleMostProducts = [...copyData, ...this.saleMostProducts.map(item => {
		// 			item.id = Math.random().toString(36).substring(2, 9 + 2);
		// 			item.brandName = item.brandName + item.id
		// 			console.log(Math.floor((Math.random()*arrPicList.length)))
		// 			item.pic = arrPicList[Math.floor((Math.random()*arrPicList.length))]
		// 			return item
		// 		})]
		// 		uni.hideLoading()
		// 	},1000)
			
		// },
		methods: {
			contact(e){
				// uni.showLoading({
					
				// })
				// uni.hideLoading()
				// uni.showToast({
				// 	 title: "logo",
				// 	 // image: "/static/uni.png",
				// 	 success: function (res) {
				// 		this.exeRet = "success:" + JSON.stringify(res) + new Date()
				// 	 },
				// 	 fail: function (res) {
				// 		this.exeRet = "fail:" + JSON.stringify(res)
				// 	 },
			 //   })
			},
			goSeries(val){
				// uni.navigateTo({
				// 	url:`/kindPackage/list/info/info?productId=${val}`
				// })
			},
			async init() {
				// await 已同步的方式去书写异步的代码
				// 轮播数据
				// this.bannerList = (await bannerList()).data.items;
				// // 分类
				// this.kindList = (await findCategory()).data.category.children;
				// // 限时活动
				// this.recommendList = (await recommendList()).data.items;
				// // 热门推荐
				// this.hotList = (await hotList()).data.items;
				// // 新品推荐
				// this.lejuLatestProducts = (await lejuLatestProducts()).data.productList;
				// // 猜你喜欢
				this.saleMostProducts = this.saleMostProducts
				// this.saleMostProducts = (await saleMostProducts()).data.items;
				// uni.stopPullDownRefresh()
			}
		}
	}
</script>

<style lang="scss" scoped>
.home {
	.tops{
		position: fixed;
		top: 0;
		left: 0;
		width: calc(100% - 60rpx);
		z-index: 9999;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: $base-padding;
		image{
			width: 42rpx;
			height: 42rpx;
			display: block;
		}
		.leftBox{
			border: none;
			height: 42rpx;
			display: flex;
			align-items: center;
			line-height: 1;
		}
		.leftBox::after {
			display: none;
		}
		.right{
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: flex-end;
			.cart{
				margin-left: 46rpx;
			}
		}
		
	}
	.banner {
		.swiper-banner {
			width: 100%;
			height: 362rpx;

			.swiper-item {
				width: 750rpx;
				height: 100%;
				border-radius: 0 0 30rpx 30rpx;
				overflow: hidden;
				.img {
					width: 100%;
					height: 100%;
				}
			}
		}
	}
	.section-kinds {
		width: 100%;
		margin: 60rpx auto;
		display: flex;
		justify-content: space-around;
		flex-wrap: wrap;
		align-items: center;

		.kind-block {
			width: 120rpx;
			text-align: center;

			.icon-kind {
				width: 80rpx;
				height: 80rpx;
				border-radius: 8rpx;
			}

			.kind-text {
				font-size: 32rpx;
				color: #3e3e3e;
				text-align: center;
			}
		}
	}
	.section-notify {
		// position: relative;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		width: 670rpx;
		height: 96rpx;
		margin: 40rpx auto;
		background-color: #fff;
		font-size: 28rpx;
		color: #3e3e3e;
		line-height: 96rpx;
		text-indent: 0.5em;

		.icon-notify {
			width: 48rpx;
			height: 48rpx;
			margin-left: 30rpx;
			animation: notifyA 0.5s 1s linear infinite both;
		}

		.text {
			font-weight: 600;
			color: orange;
		}

		.recommend-swiper {
			// width: calc(100% - 268rpx);
			flex: 1;
			height: 96rpx;
			.recommend-item {
				.nav-item {
					display: flex;
					width: 100%;
					height: 100%;
					justify-content: flex-start;
					align-items: center;
				}
				.product-name {
					width: 250rpx;
					display: inline-block;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}
				.product-price {
					.text {
						font-size: 24rpx;
						line-height: 30rpx;
					}
				}
			}
		}
	}
	.section-series {
		padding: 0 $base-padding;
		padding-bottom: 10rpx;
		.common-title {
			padding: $base-padding 0;
			font-family: PingFangSC-Semibold;
			font-size: 32rpx;
			color: #3e3e3e;
			letter-spacing: 1px;
			font-weight: 600;
		}
		.newProduct {
			// height: 314rpx;
			white-space: nowrap;
			// /deep/ .uni-scroll-view-content{
			// 	// display: flex;
			// 	// align-items: center;
			// 	// justify-content: flex-start;
			// 	white-space: nowrap;
			// }
			.series-block {
				width: 590rpx;
				// height: 314rpx;
				// padding-top: 54rpx;
				display: inline-block;
				margin-right: 20rpx;
				position: relative;
				// display: flex;
				// align-items: flex-end;

				.image {
					position: absolute;
					left: 44rpx;
					top: 0;
					bottom: 0;
					width: 194rpx;
					height: 168rpx;
					border-radius: 8rpx;
					margin: auto;
				}
				.newProductBox {
					// width: 100%;
					padding-left: 270rpx;
					padding-top: 50rpx;
					padding-bottom: 50rpx;
					height: 160rpx;
					background: #ffffff;
					box-shadow: 0 16rpx 48rpx 0 rgba(122, 98, 75, 0.12);
					border-radius: 20rpx;
					display: flex;
					flex-wrap: wrap;

					justify-content: space-between;
					// flex-direction: column;
					.cname,
					.ename {
						font-family: PingFangSC-Semibold;
						font-size: 26rpx;
						color: #3e3e3e;
						letter-spacing: 1.86rpx;
						// overflow: hidden;
						// text-overflow: ellipsis;
						// white-space: break-spaces;
						width: 100%;
					}
					.cname {
						height: 72rpx;
						// overflow: hidden;
						display: -webkit-box;
						-webkit-line-clamp: 2;
						overflow: hidden;
						text-overflow: ellipsis;
						-webkit-box-orient: vertical;
						white-space: normal;
					}
					.squote {
						display: flex;
						align-items: center;
						margin: 20rpx 0;
						.dots {
							width: 20rpx;
							height: 20rpx;
							border-radius: 100%;
							margin: 0 4rpx;
						}
					}
				}
			}
		}
		.box {
			display: flex;
			align-items: center;
			position: relative;
			overflow: hidden;
		}
		.left,
		.right {
			position: absolute;
			left: 0;
			top: 0;
		}
		.left {
			animation: fir 20s linear infinite;
			animation-delay: 2s;
		}
		.right {
			animation: sec 20s linear infinite;
			animation-delay: 20s;
		}
		@keyframes fir {
			0% {
				transform: translateX(0);
			}
			100% {
				transform: translateX(-100%);
			}
		}
		@keyframes sec {
			0% {
				transform: translateX(100%);
			}
			100% {
				transform: translateX(0%);
			}
		}
		.left {
			-webkit-animation: fir 20s linear infinite;
			animation: fir 20s linear infinite;
		}
		.right {
			-webkit-animation: sec 20s linear infinite;
			animation: sec 20s linear infinite;
		}
		.scroll-series {
			width: 100%;
			white-space: nowrap;
			display: flex;
			align-items: center;

			.series-block {
				display: inline-block;
				margin: 0 20rpx;
				width: 208rpx;

				.image {
					width: 208rpx;
					height: 176rpx;
				}

				.cname {
					font-size: 26rpx;
					line-height: 38rpx;
					color: #3e3e3e;
					text-align: center;
					margin-top: 20rpx;
					font-weight: 600;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.ename {
					font-size: 20rpx;
					color: #b0b0b0;
					line-height: 28rpx;
					text-align: center;
				}
			}
		}
	}
}
//瀑布流
.pubu-box {
	margin-bottom: 20rpx;
	animation: fadein .5s;
	.pubu-item {
		column-count: 2;
		column-gap: 20rpx;
		.item-masonry {
			box-sizing: border-box;
			border-radius: 15rpx;
			overflow: hidden;
			background-color: #fff;
			break-inside: avoid;
			/*避免在元素内部插入分页符*/
			box-sizing: border-box;
			margin-bottom: 20rpx;
			// box-shadow: 0px 0px 28rpx 1rpx rgba(78, 101, 153, 0.14);
			image {
				width: 100%;
			}
			.text-area {
				padding: 36rpx;
				font-size: 26rpx;
			
				.gname {
					color: #3e3e3e;
					line-height: 38rpx;
					margin-top: 8rpx;
					font-weight: bold;
					text-overflow: ellipsis;
					overflow: hidden;
					white-space: nowrap;
				}
			
				.price-origin {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-top: 20rpx;
			
					.origin {
						color: #3e3e3e;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
					}
				}
			}
		}
		
	}
}
   
@keyframes notifyA {
	from {
		opacity: 0.5;
	}

	to {
		opacity: 1;
	}
}

@keyframes fadein {
    // %0 可以使用 from
    0% {
        transform: translate(-100%,0);
		opacity: 0.5;
    }
    // %100 可以使用 to
    100% {
        transform: none;
		opacity: 1;
    }
}
</style>
